use std::any::Any;
use std::sync::Arc;
use crate::business::service::config_service::ConfigService;
use crate::business::service::dept_service::DeptService;
use crate::business::service::dicts_data_service::DictsDataService;
use crate::business::service::dicts_type_service::DictsTypeService;
use crate::business::service::logs_service::LogsService;
use crate::business::service::menu_service::MenuService;
use crate::business::service::post_service::PostService;
use crate::business::service::role_dept_service::RoleDeptService;
use crate::business::service::role_menu_service::RoleMenuService;
use crate::business::service::role_service::RoleService;
use crate::business::service::tenant_service::TenantService;
use crate::business::service::user_post_service::UserPostService;
use crate::business::service::user_role_service::UserRoleService;
use crate::business::service::user_service::UserService;
use crate::extends::core::context::app_context_beans::AppContextBeans;

pub fn apps_auto_service(db_pool: sqlx::MySqlPool) -> AppContextBeans {
    let mut app_context_beans = AppContextBeans::new();
    app_context_beans.add_beans(vec![
        ("config_service", Arc::new(ConfigService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("dept_service", Arc::new(DeptService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("dicts_data_service", Arc::new(DictsDataService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("dicts_type_service", Arc::new(DictsTypeService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("logs_service", Arc::new(LogsService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("menu_service", Arc::new(MenuService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("post_service", Arc::new(PostService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("role_dept_service", Arc::new(RoleDeptService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("role_menu_service", Arc::new(RoleMenuService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("role_service", Arc::new(RoleService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("tenant_service", Arc::new(TenantService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("user_post_service", Arc::new(UserPostService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("user_role_service", Arc::new(UserRoleService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
        ("user_service", Arc::new(UserService::new(db_pool.clone())) as Arc<dyn Any + Send + Sync>),
    ]);

    app_context_beans
}
